<template>
  <div class="rights">
    <mianbaoxie />
    <el-card class="box-card">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="#" label="#" type="index"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column prop="level" label="权限等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level*1===0">{{scope.row.level*1+1}}级权限</el-tag>
            <el-tag type="success" v-if=" scope.row.level*1===1">{{scope.row.level*1+1}}级权限</el-tag>
            <el-tag type="warning" v-if="scope.row.level*1===2">{{scope.row.level*1+1}}级权限</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import mianbaoxie from "../components/mianbaoxie.vue";
import { initrights } from "@/ulits/api/rights";
export default {
  components: { mianbaoxie },
  name: "rights",
  data() {
    return {
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
    };
  },
  created() {
    // 初始化数据
    initrights().then((res) => {
      this.Message(res);
      this.tableData = res.data;
    });
  },
  methods: {
    // 消息提示
    Message(res) {
      if (res.meta.status >= 200 && res.meta.status < 300) {
        this.$message({
          message: res.meta.msg,
          type: "success",
        });
      } else {
        this.$message({
          message: res.meta.msg,
          type: "error",
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.rights {
  .text {
    font-size: 14px;
  }

  .item {
    padding: 18px 0;
  }

  .box-card {
    width: 100%;
  }
}
</style>